# test.py
import sys
import io

# 设置中文输出编码
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

from alg import triangleNumber

def test():
    test_cases = [
        ([2, 2, 3, 4], 3),
        ([4, 2, 3, 4], 4),
        ([0, 0, 0], 0),
        ([1, 1, 1], 1),
        ([1, 2, 3, 4, 5], 3),
    ]

    for i, (nums, expected) in enumerate(test_cases, 1):
        result = triangleNumber(nums)
        print(f"测试用例 {i}: 输入: {nums}")
        print(f"期望输出: {expected}, 实际输出: {result}")
        print("✅ 通过\n" if result == expected else "❌ 未通过\n")

if __name__ == "__main__":
    test()
